const wx2my = require('../../wx2my');

// pages/door_check/door_check.js
const app = getApp();
Page({
  data: {
    openSus: true
  },
  onLoad: function (e) {
    this.setData({
      macno: e.macno
    });
  },
  onReady: function () {},
  onShow: function () {},

  get_detail() {
    let that = this;
    app.wxRequest('inspect', {
      'token': wx2my.getStorageSync('token'),
      'macno': that.data.macno,
      'caseno': that.data.type
    }, function (res) {
      console.log(res);

      if (res.data.code == 1) {
        that.setData({
          openSus: false
        });
        setTimeout(() => {
          that.setData({
            openSus: true
          });
        }, 3000);
      } else {
        app.toast(res.data.msg);
      }
    });
  },

  one() {
    let that = this;
    that.setData({
      type: 1
    });
    that.get_detail();
  },

  two() {
    let that = this;
    that.setData({
      type: 2
    });
    that.get_detail();
  },

  all() {
    let that = this;
    that.setData({
      type: 3
    });
    that.get_detail();
  },

  onHide: function () {},
  onUnload: function () {},
  onPullDownRefresh: function () {},
  onReachBottom: function () {},
  onShareAppMessage: function () {}
});